﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;
using System.Configuration;

using DM_Article.Model;
using DM_Article.Bll;

public partial class content : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        int id = Convert.ToInt32(Request["id"]);
        //increaseHits(id);
        articleBind(id);
    }

    private void increaseHits(int id)
    {
        using (OleDbConnection cn = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionStringAccess"].ConnectionString))
        {
            cn.Open();
            articlebll.increaseHits(cn, id);
        }
    }

    private void articleBind(int articleId)
    {
        using (OleDbConnection cn = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionStringAccess"].ConnectionString))
        {
            cn.Open();
            article art = new article();
            art = articlebll.getArticleDetail(cn, articleId.ToString());
            this.position.Text = getPositon(cn, art.bigclassid, art.smallclassid);
            this.title.Text = art.title;
            this.Title += this.title.Text;
            this.author.Text = art.author;
            this.date.Text = art.addtime.Substring(0, 10);
            this.hits.Text = art.hits.ToString();
            this.articletext.InnerHtml = art.content;
            this.keyword.Text = art.keyword;
            this.source.Text = art.origin;
        }
        return;
    }

    private string getPositon(OleDbConnection conn, int bigClassId, int smallClassId)
    {
        string position;
        position = bigclassbll.getBigclassDetail(conn, bigClassId.ToString()).bigclassname;
        position += " > ";
        position += smallclassbll.getSmallclassDetail(conn, smallClassId.ToString()).smallclassname;
        position += " > ";
        return position;
    }
}